package com.shujia.controller;

import com.shujia.service.UserServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    private UserServiceImpl userService = new UserServiceImpl();

    /**
     * http://localhost:8080/login?username=zhangsan&password=12li
     */
    @GetMapping("/login")
    public String login(String username, String password) {

        String login = userService.login(username, password);
        return login;
    }

    /**
     * http://localhost:8080/register?username=zhangsan&password=12li&nowPassword=12li
     */
    @GetMapping("/register")
    public String register(String username, String password, String nowPassword) {

        String register = userService.register(username, password, nowPassword);
        return register;
    }

    /**
     * http://localhost:8080/modifyPassword?username=zhangsan&oldPassword=123&newPassword=123456&nowPassword=123456
     */
    @GetMapping("/modifyPassword")
    public String modifyPassword(String username, String oldPassword, String newPassword, String nowPassword) {

        String s = userService.modifyPasswordByUsername(username, oldPassword, newPassword, nowPassword);
        return s;
    }

}
